﻿using System;
using System.Collections.Generic;
using Assist;
using Autodesk.Revit.Attributes;
using Autodesk.Revit.DB;
using Autodesk.Revit.UI;
using Autodesk.Revit.UI.Selection;

namespace YJKArch.WallModule
{
	[Regeneration(RegenerationOption.Manual)]
	[Transaction(TransactionMode.Manual)]
	public class CmdShowSameWalls : IExternalCommand
	{
		public Result Execute(ExternalCommandData cmdData, ref string message, ElementSet elements)
		{
			Transaction transaction = new Transaction(cmdData.Application.ActiveUIDocument.Document, this.ToString());
			transaction.Start();
			transaction.Commit();
			return Autodesk.Revit.UI.Result.Succeeded;
		}

		private void FindSpecialWalls(UIDocument uiDoc, Wall refWall)
		{
			FilteredElementCollector filteredElementCollector = new FilteredElementCollector(uiDoc.Document);
			filteredElementCollector.OfClass(typeof(Wall));
			IEnumerable<Element> enumerable = filteredElementCollector.ToElements();
			Selection selection = uiDoc.Selection;
			RevitVersionFuncs.ClearSelection(selection);
			List<Element> list = new List<Element>();
			foreach (Element element in enumerable)
			{
				Wall wall = element as Wall;
				if (wall != null && wall.WallType.Id.Equals(refWall.WallType.Id))
				{
					list.Add(wall);
				}
			}
			RevitVersionFuncs.SetSelection(selection, list);
		}

		public Wall m_refWall;
	}
}
